//
//  GHCollectionViewCell.m
//  Diary
//
//  Created by lanou3g on 15/10/27.
//  Copyright © 2015年 王艺拓. All rights reserved.
//

#import "GHCollectionViewCell.h"

#define kWidth self.frame.size.width
#define kHeight self.frame.size.height

@implementation GHCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addViews];
    }
    return self;
}

- (void)addViews
{
    // 背景
    UIImageView *bg_imagV = [[UIImageView alloc] initWithFrame:CGRectMake((kWidth - kWidth * 0.8)/2, (kHeight - kHeight * 0.8) / 2, kWidth * 0.8, kHeight *0.8)];
    //    bg_imagV.backgroundColor = [UIColor redColor];
    [self addSubview:bg_imagV];
    
    // 图片
    self.pic_imgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(bg_imagV.frame), kHeight * 0.5)];
    self.pic_imgV.backgroundColor = [UIColor orangeColor];
    [bg_imagV addSubview:self.pic_imgV];
    
    // 标题
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.pic_imgV.frame), CGRectGetWidth(bg_imagV.frame), kHeight * 0.1)];
    //    self.titleLabel.backgroundColor = [UIColor greenColor];
    self.titleLabel.text = @"日记标题名";
    [bg_imagV addSubview:self.titleLabel];
    
    // 横线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.titleLabel.frame), CGRectGetWidth(bg_imagV.frame), kHeight *0.02)];
    lineView.backgroundColor = [UIColor blackColor];
    [bg_imagV addSubview:lineView];
    
    // 日记内容
    self.summaryLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(lineView.frame), CGRectGetWidth(bg_imagV.frame), kHeight * 0.3)];
    //    self.summaryLabel.backgroundColor = [UIColor grayColor];
    self.summaryLabel.numberOfLines = 0;
    self.summaryLabel.text = @"搜房鸡尾酒佛山的金佛阿斯顿第三方就暗示都放假几乎是减肥了开始节点看看就离开教室里的咖啡机类库看见了看见看来看看健康立即";
    [bg_imagV addSubview:self.summaryLabel];
    
    [self fitFont];
    
}

// 适配字体
- (void)fitFont
{
    if ([WYTDevicesTool iPhone320_DEVICES]) {
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.summaryLabel.font = [UIFont systemFontOfSize:12];
    } else if ([WYTDevicesTool iPhone4_iPhone4s]) {
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.summaryLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone5_iPhone5s_iPhone5c]) {
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.summaryLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone6_iPhone6s]) {
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.summaryLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhone6Plus_iPhone6sPlus]) {
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.summaryLabel.font = [UIFont systemFontOfSize:13];
    } else if ([WYTDevicesTool iPhoneNONE_PLUS]) {
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.summaryLabel.font = [UIFont systemFontOfSize:13];
    }
}


@end
